<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="UTF-8" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%
	String port = request.getServerPort() == 80 ? "" : ":".concat(request.getServerPort()+"");
	String path = request.getScheme().concat("://").concat(request.getServerName()).concat(port).concat(request.getContextPath());
	request.setAttribute("path", path);
%>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<!DOCTYPE html>
<html>
<head>
<title>用户修改 - 个人中心 - IT答案网</title>
<meta name="keywords" content="用户修改" />
<meta name="description" content="用户修改" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="${path }/view/portal/css/all.css" rel="stylesheet">
<link href="${path }/view/portal/css/prettify.css" rel="stylesheet">
<script src="${path }/view/portal/js/all.js"></script>
</head>
<body>
  <jsp:include page="head.jsp"></jsp:include>
  <div class="container container1000">
	<div class="content">
		<form class="form-horizontal" method="post" action="${ctx }/user/user/save">
			<input type="hidden" name="id" value="${user.id}" />
		
			<div class="control-group">
				<label class="control-label">用户名</label>
				<div class="controls">
					<input type="text"  name="username" value="${user.username }" <shiro:lacksRole name="admin">disabled="disabled"</shiro:lacksRole>/>
				</div>
			</div>
			<shiro:hasRole name="admin">
			<div class="control-group">
				<label class="control-label">密码</label>
				<div class="controls">
					<input type="password"  name="password" value="${user.password }">
				</div>
			</div>
			<div class="control-group">
				<label class="control-label">重复密码</label>
				<div class="controls">
					<input type="password"  name="repeatPassword" value="${user.repeatPassword }">
				</div>
			</div>
			</shiro:hasRole>
			<div class="control-group">
				<label class="control-label">昵称</label>
				<div class="controls">
					<input type="text"  name="name" value="${user.name }" <shiro:lacksRole name="admin">disabled="disabled"</shiro:lacksRole>>
				</div>
			</div>
			<div class="control-group">
				<label class="control-label">拥有角色</label>
				<div class="controls">
					<table class=" table-bordered table-striped table-condensed">
							<thead>
								<tr>
									<th>
										<input type="checkbox" id="selectall" onChange="selectAll('selectall','roleIds');" <shiro:lacksRole name="admin">disabled="disabled"</shiro:lacksRole>>
									</th>
									<th>
										角色名
									</th>
								</tr>
							</thead>
							<tbody>							
								<c:forEach items="${roles}" var="data" >
								<c:set value="" var="checked"/>
								<tr>
									<c:forEach items="${roleIds }" var="innerData">
									    <c:if test="${innerData==data.id}">
									      <c:set value="checked" var="checked"/>
									    </c:if>
									</c:forEach>
									<td><input type="checkbox" name="roleIds" value="${data.id}" ${checked } <shiro:lacksRole name="admin">disabled="disabled"</shiro:lacksRole>></td>
									<td>${data.name}</td>
								</tr>
								</c:forEach>
							</tbody>
						</table>
				</div>
			</div>
			<shiro:hasRole name="admin">
			<div class="control-group">
				<div class="controls">
					<input type="submit" class="btn" value="保存">
				</div>
			</div>
			</shiro:hasRole>
		</form>
	
	</div>
  </div>
	<script src="${ctx}/view/user/js/common.js"></script>
	
  <div class="clear">&nbsp;</div>
   
  <jsp:include page="bottom.jsp"></jsp:include>  
</body>
</html>	